package club.weiyuanstudio.java.eedemo;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Printer {
    private static final String PLUGIN_CLASS_PATH = "club.weiyuanstudio.java.eedemo.plugins.";

    private String content;
    private String pluginName;

    public Printer(String content, String pluginName) {
        this.content = content;
        this.pluginName = pluginName;
    }


    public void print() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class c = Class.forName(PLUGIN_CLASS_PATH + pluginName);
        Constructor con = c.getConstructor();
        Object inst = con.newInstance();

        System.out.println(((PrinterPlugin)inst).getPluginIntro());
        System.out.println(((PrinterPlugin)inst).getBeautifulOutput(content));
    }
}
